package org.dengyiqian.fraud;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public record FraudReviewService(FraudCheckHistoryRepository fraudCheckHistoryRepository) {
    private static final Logger log = LoggerFactory.getLogger(FraudReviewService.class);

    public boolean isFraudulentCustomer(String customerEmail) {
        List<FraudCheckHistory> fraudHistories = fraudCheckHistoryRepository
                .findAllByEmailAndIsFraudster(customerEmail, true);
        log.info("Fraud check customer with Email: {}, has {} record(s).", customerEmail, fraudHistories.size());
        return !fraudHistories.isEmpty();
    }
}